<?
include_once('config.php');
include_once('model/users.php');

	$user = new Users();
	$user->name 				= $_POST['name'];
	$user->address 				= $_POST['address'];
	$user->hometown 			= $_POST['hometown'];
	$user->current_city 		= $_POST['current_city'];
	$user->gender 				= $_POST['gender'];
	$user->birthdate 			= $_POST['birthdate'];
	$user->about_me 			= $_POST['about_me'];
	$user->relationship_status 	= $_POST['relationship_status'];
	$user->email_ad1 			= $_POST['email_ad1'];
	 $user->username 			= $_POST['email_ad1'];
	 $user->password 			= $_POST['password'];
	$user->email_ad2 			= $_POST['email_ad2'];
	$user->phone_number1 		= $_POST['phone_number1'];
	$user->phone_number2 		= $_POST['phone_number2'];
	$user->website 				= $_POST['website'];

	try{
		if($user->insert()){
			// create the session. After this, $_SESSION will be available to our files
			Session::start($user->username);
			header("Location: wall.php");
		}
	}
	catch(Exception $e){
		Session::set_error($e->getMessage());
	}	
	header("Location: login.php");
	
?>